/**
 * The file for the MarketPlace class.
 */

package edu.gatech.information;

/**
 * The Class MarketPlace.
 * @author Hippie Mind Control
 * @version 1.0
 */
public class MarketPlace {
	/** The orig price. */
	private int[] origPrice = new int[] {10, 15, 20, 25, 30, 35, 40, 45, 50, 55}; 
	
	/** The orig stock. */
	private int[] origStock = new int[] {10, 10, 8, 8, 6, 6, 4, 4, 4, 4}; 
	
	/** The final price. */
	private int[] finalPrice;
	
	/** The final stock. */
	private int[] finalStock;

	/**
	 * The Enum ResourceType.
	 */
	public enum ResourceType {
		
		/** The Water. */
		WATER,
		
		/** The Furs. */
		FURS,
		
		/** The Food. */
		FOOD,
		
		/** The Ore. */
		ORE,
		
		/** The Games. */
		GAMES,
		
		/** The Firearms. */
		FIREARMS,
		
		/** The Medicine. */
		MEDICINE,
		
		/** The Machines. */
		MACHINES,
		
		/** The Narcotics. */
		NARCOTICS,
		
		/** The Robots. */
		ROBOTS,
		
		/** The Fuel. */
		FUEL,
	}

	/**
	 * Instantiates a new market place.
	 *
	 * @param econMod the econ mod
	 * @param governMod the govern mod
	 * @param specialRes the special res
	 */
	public MarketPlace(int[] econMod, int[] governMod, int[] specialRes){
		finalStock = new int[origStock.length + 1];
		finalPrice = new int[origStock.length + 1];
		for(int i = 0; i < origStock.length; i++){
			finalStock[i] = governMod[i] * origStock[i] * specialRes[i];
			finalPrice[i] = econMod[i] * origPrice[i];
		}
		//Fuel Stock
		finalStock[origStock.length] = 100;
		
		//Fuel Price
		finalPrice[origStock.length] = 5;
	}

	/**
	 * Gets the final price.
	 *
	 * @return the final price
	 */
	public int[] getFinalPrice() {
		return finalPrice;
	}

	/**
	 * Gets the final stock.
	 *
	 * @return the final stock
	 */
	public int[] getFinalStock() {
		return finalStock;
	}
	
	/**
	 * Sets the final stock.
	 *
	 * @param finalStock The new final stock
	 */
	public void setFinalStock(int[] finalStock) {  
		System.arraycopy(finalStock, 0, this.finalStock, 0, finalStock.length);
	}
	
	/**
	 * Adds an item the player sells to the stock of the market place.
	 * @param index
	 */
	public void addStockTo(int index){
		finalStock[index]++;
	}
	
	/**
	 * Removes an item that the player buys from the stock of the market place.
	 * @param index
	 */
	public void removeStockFrom(int index){
		finalStock[index]--;
	}
	
	/**
	 * Returns a string version of the market.
	 * @return The market in string form.
	 */
	public String toString(){
		return "Marketplace";
	}
}
